package com.algorithms.contests.srm481rn1;

public class AfraidOfEven
{
	public static void main(String args[])
	{
		AfraidOfEven service= new AfraidOfEven();
		service.restoreProgression(new int[] {9, 7, 5, 3, 1});
	}
	public int[] restoreProgression(int[] input)
	{
		int a,b,c,d;
		int ma,mb,mc,md;
		int[] output = null;
		for(int i=0;i<=9;i++)
		{
			ma=(int) Math.pow(2,i);
			a=input[0]*ma;
			for(int j=0;j<=9;j++)
			{
				 mb=(int) Math.pow(2,j);
				 b=input[1]*mb;
				for(int k=0;k<=9;k++)
				{
					 mc=(int) Math.pow(2,k);
					 c=input[2]*mc;
					for(int l=0;l<=9;l++)
					{
						 md=(int) Math.pow(2,l);
						 d=input[3]*md;
						 if(validateNumber(a,b,c,d) ==0)
						 {
							return formOutput(a,(b-a),input.length);
							
						 }
					}
				}
			}
		}
		return null;
	}
	public int validateNumber(int a,int b,int c,int d )
	{
		int diff= b-a;
		if((c-b)==diff && (d-c)==diff)
		{
			return 0;
		}
		return 1;
	}
	
	public int[] formOutput(int start,int diff,int size)
	{
		int[] output = new int[size];
		output[0]=start;
		System.out.println(output[0]);
		for(int i=1;i< size;i++)
		{
			output[i]=output[i-1]+ diff;
			System.out.println(output[i]);
		}
		return output;
	}
}
